package com.hdoit.ares.web.personnel.providers;

import java.util.ArrayList;
import java.util.List;

import com.tennetcn.common.aop.CommonApplicationContextUtil;
import com.tennetcn.common.logical.superbase.model.Business;
import com.tennetcn.common.message.ListItem;
import com.tennetcn.component.attribute.provider.ISingleOptionListProvider;
import com.tennetcn.component.web.SessionWebFactory;
import com.tennetcn.web.cbase.providers.base.DataListProviderBase;

public class PersonnelBusinessProvider extends DataListProviderBase implements ISingleOptionListProvider<ListItem>{
	
	@Override
	public List<ListItem> getDataList(Object viewData) {
		List<Business> businessList=getBusinessList();
		if(businessList==null||businessList.size()<=0){
			return null;
		}
		dataList=new ArrayList<ListItem>();
		ListItem item;
		for (Business business : businessList) {
			item=new ListItem();
			item.setText(business.getName());
			item.setValue(business.getBuId());
			
			dataList.add(item);
		}
		return dataList;
	}

	private List<Business> getBusinessList(){
		SessionWebFactory sessionWebFactory=CommonApplicationContextUtil
				.getCurrentContext().getBean(SessionWebFactory.class);
		Business business=(Business)sessionWebFactory.getCurrentLogin()
				.getArgument("business");

		List<Business> businessList=new ArrayList<Business>();
		businessList.add(business);
		return businessList;
	}
/*	
	private List<Role> getRoles(){
		SessionWebFactory sessionWebFactory=CommonApplicationContextUtil.getCurrentContext().getBean(SessionWebFactory.class);
		Business business=(Business)sessionWebFactory.getCurrentLogin().getArgument("business");
		
		IRoleService roleService=CommonApplicationContextUtil.getCurrentContext().getBean(IRoleService.class);
		RoleSearch roleSearch=new RoleSearch();
    	roleSearch.setBuId(business.getBuId());
    	
    	List<Role> roles=roleService.queryList(roleSearch);
    	
    	return roles;
	}*/
}
